//
//  CMDBFilterCollectionView.swift
//  CMDB
//
//  Created by 曹桂祥 on 17/4/26.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

private let FilterCollectionCellID = "FilterCollectionCell"

class CMDBFilterCollectionView: BaseCollectionView {

    var dataList : [AnyObject] = [AnyObject](){
        
        didSet{
            
            reloadData()
            
        }
        
    }
    
    override func commitInitOwnProperties() {
        super.commitInitOwnProperties()
        
        backgroundColor = UIColor.whiteColor()
        
        let layout      = collectionViewLayout as! UICollectionViewFlowLayout
        
        layout.minimumLineSpacing = 10
        
        layout.minimumInteritemSpacing = KleftMargin
        
        registerClass(CMDBFilterCollectionViewCell.self, forCellWithReuseIdentifier: FilterCollectionCellID)
    }
}


extension CMDBFilterCollectionView{
    
    override func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
        
        return CGSize(width: 170 * CMDB_Rate, height: 70 * CMDB_Rate)
        
    }
    
    override func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
        return UIEdgeInsetsMake(5, 15, 10, 20)
    }
    
    override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        printLog("collection click")
    }
    
}


extension CMDBFilterCollectionView{
    
    override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return 3
    }
    
    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(FilterCollectionCellID, forIndexPath: indexPath) as! CMDBFilterCollectionViewCell
        
        cell.mDelegate = self
        
        return cell
    }
}


extension CMDBFilterCollectionView{
    override func onItemClickType(itemClickType: String?, data: AnyObject?, indexPath: NSIndexPath?) {
        printLog("collectionView change")
//        mDelegate?.onItemClickType!("", data: nil, indexPath: nil)
    }
    
}